/**
 * 支付
 * 参数：
 * timeStamp: '',
 * nonceStr: '',
 * package: '',
 * signType: 'MD5',
 * paySign: '',
 */

const uniPay = obj => {
	return new Promise((resolve, reject) => {
		uni.requestPayment({
			provider: 'wxpay',
			timeStamp: obj.timeStamp,
			nonceStr: obj.nonceStr,
			package: obj.package,
			signType: obj.signType,
			paySign: obj.paySign,
			success: res => {
				// console.log(res)
				uni.showToast({
					title: '支付成功',
					icon: "success",
					duration: 1500,
				})
				setTimeout(() => {
					resolve(obj)
				}, 1500)
			},
			fail: err => {
				reject(err)
			},
			complete: res => {
				console.log('支付完成', res)
				// resolve(res)
			}
		});
	})
}

export default uniPay
